﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EditTeams.ascx.cs" Inherits="PickEmHats.UserControls.EditTeams" %>
<script>
    $(function () {
        $("#editTeamDialog").dialog({
            height: 600,
            width: 800,
            modal: true,
            draggable: false,
            autoopen: false,
            show: {
                effect: "scale",
                duration: 300
            },
            hide: {
                effect: "scale",
                duration: 300
            }
        });
    });
    $(function showTeamModal() {
        $(".selector").dialog("option", "show");
    })
    $(function hideTeamModal() {
        $(".selector").dialog("option", "hide");
    })
    function SubmitTeam() {
        $.ajax({
            type: "POST",
            url: "AdminPanel.aspx/SubmitTeam",
            data: '{name: "' + txtName.value + '" ,'+
                  'city: "' + txtCity.value + '" ,'+
                  'abbr: "' + txtAbbr.value + '" }',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccess,
            failure: function (response) {
                alert(response.d);
            }
        });
    }
    function OnSuccess(response) {
        hideTeamModal();
    }
</script>
<asp:ScriptManager ID="scManager" runat="server" EnablePageMethods="true"></asp:ScriptManager>


<div id="editTeamDialog" title="Edit Team" class="ui-dialog" style="text-align: center;">
    <asp:UpdatePanel ID="updTeamMod" runat="server" ChildrenAsTriggers="true">
        <ContentTemplate>

            <asp:GridView ID="gvEditTeams" runat="server" AutoGenerateColumns="false" OnRowCommand="gvEditTeams_RowCommand">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="btnModTeam" runat="server" Text="Mod" CommandName="Mod" CommandArgument='<%#Eval("id")%>' CssClass="selector" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="name" HeaderText="Team Name" />
                    <asp:BoundField DataField="city" HeaderText="City/State/Region" />
                    <asp:BoundField DataField="abbreviation" HeaderText="Abbreviation" />
                </Columns>
            </asp:GridView>
            <div class="selector">
                <label>Add New Team</label>
                <label>Name:</label><input id="txtName" style="width: 200px" />
                <label>City:</label><input id="txtCity" style="width: 200px" />
                <label>Abbr:</label><input id="txtAbbr" style="width: 200px" />
                <input type="button" class="ui-button" value="Submit New Team" onclick="SubmitTeam()" />
            </div>

        </ContentTemplate>
    </asp:UpdatePanel>
</div>

